﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Arizu.Repository;
using System.Data;
using System.Text;

namespace AiRiZu.User
{
    public partial class Unread : Common
    {
        public string UnreadMessages { get; set; }

        public int MessagesCount { get; set; }

        public int UnreadMessagesCount { get; set; }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["logId"] == null)
            {
                return;
            }

            AirizuMessage aMessage = AirizuMessage.CreateInstance();

            DataTable dt = aMessage.GetUnreadMesage(int.Parse(Session["logId"].ToString()));

            DataTable dtcount = aMessage.GetMesageCount(int.Parse(Session["logId"].ToString()));

            StringBuilder sBuilder = new StringBuilder();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sBuilder.Append(dt.Rows[i]["Message"].ToString()).Append("<p>");
                    UnreadMessagesCount++;
                }
            }

            if (dtcount.Rows.Count > 0)
            {
                MessagesCount = int.Parse(dtcount.Rows[0][0].ToString());
            }

            UnreadMessages = sBuilder.ToString();
        }
    }
}
